package 赛码.滴滴;

import java.util.Scanner;

public class 连续地砖 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int mlong = sc.nextInt();
        int max = sc.nextInt();
        String s = sc.next();
        char[] chs = s.toCharArray();
        int sum =0,sum2=30,js = 0;
        for (int i=0;i<chs.length-max;i++){
            sum = 0;js =0;
            for(int k=1;k<max;k++){
                if(chs[i]!=chs[i+k]){
                    sum = sum+1;
                }else continue;
            }
            sum = sum-js;
            sum2 = sum<sum2?sum:sum2;
        }
        System.out.println(sum2);
    }
}
